package com.jms.tomcat.config;

import com.jms.tomcat.registration.JmsServletRegistration;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import java.util.Enumeration;
import java.util.Vector;

/**
 *servlet配置类
 */
public class JmsServletConfig implements ServletConfig {

    private final JmsServletRegistration servletRegistration;

    public JmsServletConfig(JmsServletRegistration servletRegistration) {
        this.servletRegistration = servletRegistration;
    }

    @Override
    public String getServletName() {
        return servletRegistration.getName();
    }

    @Override
    public ServletContext getServletContext() {
        return servletRegistration.getServletContext();
    }

    @Override
    public String getInitParameter(String name) {
        return servletRegistration.getInitParameter(name);
    }

    @Override
    public Enumeration<String> getInitParameterNames() {
        return new Vector<>(servletRegistration.getInitParameters().keySet()).elements();
    }
}
